package patrol.mobile.com.mobilepatrol.activity.security.emergency;

import android.annotation.SuppressLint;
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.List;

import butterknife.BindView;
import patrol.mobile.com.mobilepatrol.R;
import patrol.mobile.com.mobilepatrol.activity.office.HomeDataHelper;
import patrol.mobile.com.mobilepatrol.activity.office.OtherBusinessActivity;
import patrol.mobile.com.mobilepatrol.adapter.MyHomeAdapter;
import patrol.mobile.com.mobilepatrol.bean.HomeDataBean;
import patrol.mobile.com.mobilepatrol.bean.MenuBean;
import patrol.mobile.com.mobilepatrol.bean.MenuConstants;
import patrol.mobile.com.mobilepatrol.fragment.BaseFragment;

/**
 * Created by fuzhen.li on 2018/9/18.
 */
public class EmergencyYWFragment extends BaseFragment {

    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;

    protected MyHomeAdapter mAdapter;
    List<MenuBean> menuBeanList;
    public EmergencyYWFragment(){}
    @SuppressLint("ValidFragment")
    public EmergencyYWFragment(List<MenuBean> menuBeanList) {
        this.menuBeanList=menuBeanList;
    }

//    private static final String[] stringsTopYW = new  String[]{"目标管理考核", "安全生产", "综治维稳", "包联包户", "其它业务"};
//    private static final String[] stringsSub1YW = new String[]{"综合检查"};
//    private static final String[] stringsSub2YW = new String[]{"作业区专项检查", "安全检查", "安全整改"};
//    private static final String[] stringsSub3YW = new String[]{"值带班检查"};
//    private static final String[] stringsSub4YW = new String[]{"包联包户"};
//    private static final String[] stringsSub5YW = new String[]{"其它业务"};
    //private static final int[] img1 = new int[]{R.mipmap.emergency_base, R.mipmap.emergency_mechanism, R.mipmap.ntingency_plan, R.mipmap.emergency_rehearsal, R.mipmap.security_check, R.mipmap.emergency_statistics, R.mipmap.assess_pool, R.mipmap.assess_pool};
//    private static final int[] img1YW = new int[]{R.mipmap.security_check};
//    // private static final int[] img2 = new int[]{R.mipmap.organization, R.mipmap.safety_education, R.mipmap.accident_treatment, R.mipmap.accident_treatment, R.mipmap.chance_inspect, R.mipmap.periodic_inspection, R.mipmap.ectocy_administration};
//    private static final int[] img2YW = new int[]{R.mipmap.organization, R.mipmap.safety_education, R.mipmap.chance_inspect};//
//    //    private static final int[] img3 = new int[]{R.mipmap.roster, R.mipmap.equipment_summary, R.mipmap.holiday_rota, R.mipmap.check_duty, R.mipmap.comprehensive_examination, R.mipmap.packs, R.mipmap.comprehensive_examination, R.mipmap.ntingency_plan, R.mipmap.emergency_statistics, R.mipmap.chance_inspect};
//    //private static final int[] img3 = new int[]{R.mipmap.roster, R.mipmap.equipment_summary, R.mipmap.holiday_rota, R.mipmap.check_duty, R.mipmap.comprehensive_examination, R.mipmap.packs};
//    private static final int[] img3YW = new int[]{R.mipmap.check_duty};
//
//    private static final int[] img4YW = new int[]{R.mipmap.comprehensive_examination};
//    private static final int[] img5YW = new int[]{R.mipmap.other};

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_yw_1;
    }

    @Override
    protected void initView() {
        super.initView();
    }

    @Override
    protected void initData() {
        recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
        mAdapter = new MyHomeAdapter(getContext());
        recyclerView.setAdapter(mAdapter);
        mAdapter.setData(initAdapterData());
    }

    private List<HomeDataBean> initAdapterData() {
        return HomeDataHelper.getInstance().getHomeDataYW(
                MenuConstants.ABGL_TAB2_TOP_TITLES,
                MenuConstants.ABGL_TAB2_CHILD_TITLES_1,
                MenuConstants.ABGL_TAB2_CHILD_TITLES_2,
                MenuConstants.ABGL_TAB2_CHILD_TITLES_3,
                MenuConstants.ABGL_TAB2_CHILD_TITLES_4,
                MenuConstants.ABGL_TAB2_CHILD_IMG_1,
                MenuConstants.ABGL_TAB2_CHILD_IMG_2,
                MenuConstants.ABGL_TAB2_CHILD_IMG_3,
                MenuConstants.ABGL_TAB2_CHILD_IMG_4);
    }

    @Override
    protected void initTitle() {
        super.initTitle();

    }

    @Override
    public void onAttach(Context context) {
        super.onAttach(context);

    }

    @Override
    protected void initListener() {
        mAdapter.setItemClickListener(new MyHomeAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(int parentPosition, int childPosition) {
                if (parentPosition == 0) {
                    if (childPosition == 0) {
                        startActivity(EmergencyCheck1Activity.class);//
                    }

                } else if (parentPosition == 1) {
                    if (childPosition == 0) {
                        startActivity(EmergencyCuring1Activity.class);//作业区专项检查
                    } else if (childPosition == 1) {
//                        startActivity(EmergencySaveCheckLeader1Activity.class);//安全检查
                        startActivity(EmergencySaveCheck1Activity.class);//安全检查
                    } else if (childPosition == 2) {
                        startActivity(EmergencySaveCheckLeader1Activity.class);//安全检查
                    }
                } else if (parentPosition == 2) {
                    if (childPosition == 0) {
                        startActivity(EmergencyProtectCollectionActivity.class);//值带班检查
                    }
                } else if (parentPosition == 3) {
                    if (childPosition == 0) {
                        startActivity(EmergencyProtectListActivity.class);//包联包户
                    }
                } else if (parentPosition == 4) {
                    startActivity(OtherBusinessActivity.class);//包联包户
                }
            }
        });
    }

}
